package com.flyweb.config;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * Title: flyweb
 * </p>
 * 
 * <p>
 * Description: Action
 * </p>
 * 
 * <p>
 * CreateTime: 2007-Oct 14, 2007-7:24:32 PM
 * </p>
 * 
 * @author fireflyc@126.com
 */

public class Action {
	private String pattern;
	private String cls;
	private String method;
	private HttpServletResponse response;
	private HttpServletRequest request;
	private Filter before;
	private Filter after;
	private List<Result> results = new ArrayList<Result>();

	// private List<String> parameters = new ArrayList<String>();

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

	public String getCls() {
		return cls;
	}

	public void setCls(String cls) {
		this.cls = cls;
	}

	public Filter getBefore() {
		return before;
	}

	public void setBefore(Filter before) {
		this.before = before;
	}

	public Filter getAfter() {
		return after;
	}

	public void setAfter(Filter after) {
		this.after = after;
	}

	public List<Result> getResults() {
		return results;
	}

	public void addResult(Result result) {
		this.results.add(result);
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer();
		buf.append("pattern:" + this.pattern + "\n");
		buf.append("cls:" + this.cls + "\n");
		buf.append("method:" + this.method + "\n");
		buf.append("before" + this.before + "\n");
		buf.append("after" + this.after + "\n");
		Iterator<Result> iter = results.iterator();
		while (iter.hasNext()) {
			Result result = (Result) iter.next();
			buf.append("result:" + result + "\n");
		}
		return buf.toString();
	}

}
